package com.shangxia.feign.client.fallBack;

import com.shangxia.feign.client.UserClient;
import com.shangxia.feign.model.SX_User;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zhouya24
 * @date 2021/11/18 15:26
 * @apiNote
 */

@Slf4j
@Component
public class UserClientFallBackFactory implements FallbackFactory<UserClient> {

    @Override
    public UserClient create(Throwable throwable) {
        return new UserClient() {
            @Override
            public SX_User queryById(Long id) {
                log.error("userservice 服务异常", throwable);
                return new SX_User();
            }
        };
    }
}
